package com.phkj.qdh.ui.adapter

import android.content.Context
import android.view.ViewGroup
import android.widget.CheckBox
import android.widget.Checkable
import android.widget.ImageView
import com.bumptech.glide.Glide
import com.chad.library.adapter4.BaseQuickAdapter
import com.chad.library.adapter4.viewholder.QuickViewHolder
import com.hjq.shape.view.ShapeCheckBox
import com.phkj.qdh.R
import com.phkj.qdh.bean.CarKeyBean

class UseCarSubmitSelectCarAdapter :BaseQuickAdapter<CarKeyBean,QuickViewHolder>(){
    override fun onBindViewHolder(holder: QuickViewHolder, position: Int, item: CarKeyBean?) {
        holder.setText(R.id.tv_name,item?.ysName)
       val state =  holder.getView<ImageView>(R.id.iv_state)
        when (item?.ysState) {
            1 -> {
                Glide.with(context).load(R.mipmap.img_keyong).into(state)
            }
            else -> {
                Glide.with(context).load(R.mipmap.img_bukeyong).into(state)
            }
        }
        val cb = holder.getView<ShapeCheckBox>(R.id.cb)
        cb.setOnCheckedChangeListener(null)
        cb.isChecked = item!!.isSelected
    }

    override fun onCreateViewHolder(
        context: Context,
        parent: ViewGroup,
        viewType: Int
    ): QuickViewHolder {
       return QuickViewHolder(R.layout.item_car_use_select_car,parent)
    }
}